package br.ufpb.di.ppgi.utils;

import static org.mockito.Mockito.mock;

import java.util.Date;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang.RandomStringUtils;
import org.hibernate.Criteria;
import org.hibernate.Session;

import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.Validator;
import br.com.caelum.vraptor.util.test.MockResult;
import br.com.caelum.vraptor.util.test.MockValidator;
import br.ufpb.di.ppgi.negocio.modelo.usuario.Usuario;
import br.ufpb.di.ppgi.negocio.modelo.usuario.UsuarioRole;
import br.ufpb.di.ppgi.persistencia.domainstore.DomainStore;
import br.ufpb.di.ppgi.persistencia.domainstore.DomainStoreImpl;
import br.ufpb.di.ppgi.util.security.GeradorDeSenha;

public class DefaultTestSuite {
	protected static Long		idTeste			= 2099L;
	protected static String 	randomString 	= RandomStringUtils.randomAlphanumeric(8);	
	protected Validator   		validator 		= new MockValidator();
	protected Result 	  		result			= new MockResult();
	
	protected HttpSession httpSession 		= mock(HttpSession.class);	
	protected EntityManager em 				= mock(EntityManager.class);
	protected Session session 				= mock(Session.class);
	protected EntityTransaction transaction = mock(EntityTransaction.class);
	protected Criteria criteria				= mock(Criteria.class);
	protected DomainStore ds				= mock(DomainStoreImpl.class);
	
	//------------------------------------------------------------------------------------------------ UTILS
	public static Usuario factoryUsuario(String nome, String email) {
		Usuario usuario = new Usuario();
		usuario.setId(idTeste);
		usuario.setNome(nome);
		usuario.setEmail(email);
		usuario.setSenhaDescriptografada(GeradorDeSenha.ALPHA_NUMERICO.gerarSenha(10));
		usuario.setRole(UsuarioRole.SU);
		usuario.setAtivo(true);
		usuario.setCpf("628.033.443-00");
//		usuario.setDescricao("Descricao");
		usuario.setDataDeCadastro(new Date());
		usuario.setDataDeAtualizacao(new Date());
		
		return usuario;
	}	
}